import http from '../http'

const api = '/manage/user'

export function login(data) {
  return http.post(api + '/login', data, {
    params: {
      permission: process.env.VUE_APP_PERMISSION
    }
  })
}

export function logout() {
  return http.get(api + '/logout')
}

export function user() {
  return http.get(api)
}

export function update(data) {
  return http.post(api, data)
}

export function account(data) {
  return http.get(api + '/account', {
    params: data
  })
}

export function accountUpdate(data) {
  return data.id ? http.put(api + '/account/' + data.id, data) : http.post(api + '/account', data)
}

export function accountDelete(id) {
  return http.delete(api + '/account/' + id)
}

export function checkout() {
  return http.get(api + '/checkout')
}

export function checkoutUpdate(data) {
  return http.put(api + '/checkout/' + data.id, data)
}

export function checkoutToken(id) {
  return http.get(api + '/checkout/token/' + id)
}

export function checkoutClean(id) {
  return http.get(api + '/checkout/clean/' + id)
}